{extend name='public/modal'}
{block name='content'}
<style type="text/css">
  .submit_btn{
    text-align: center;margin-left: -50px;
  }
</style>
<form  id="mainForm" class="layui-form layui-form-pane" method='post' action="edit_role">
  <input type="hidden" value="{$data.id}" name="id">

  <div class="layui-form-item">
    <label class="layui-form-label">名称</label>
    <div class="layui-input-block">
      <input type="text" value="{$data.title}" name="title" required  lay-verify="required" placeholder="请输入角色名称" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">状态</label>
    <div class="layui-input-block">
         <input type="radio" name="status" value="1" title="启用" {if condition="$data['status']==1"} checked {/if}>
         <input type="radio" name="status" value="0" title="禁用"  {if condition="$data['status']==0"} checked{/if}>
    </div>
  </div>

  <div class="submit_btn" class="layui-form-item" >
    <div class="layui-input-block">
      <button   class="layui-btn" lay-submit='' lay-filter="formDemo">提交</button>
      <button   style="display: none;"  type="reset" class=" layui-btn layui-btn-primary">重置</button>
    </div>
  </div>

</form>
{/block}
{block name='js'}

  <script type="text/javascript">
      $(function(){
            var jqForm_options = {
            type:'post',           //post提交
            //url:'http://ask.tongzhuo100.com/server/****.php?='+Math.random(),   //url
            dataType:"json",        //json格式
            data:{},    //如果需要提交附加参数，视情况添加
            clearForm: false,        //成功提交后，清除所有表单元素的值
            resetForm: false,        //成功提交后，重置所有表单元素的值
            cache:false,          
            async:false,          //同步返回
            success:function(data){
                  console.log(data);
                  if(data.code==0){
                    layer.msg(data.msg);
                  }else{
                    layer.msg(data.msg,{icon:1,time:500},function(){
                      $("#reset").click();
                      lotus_close();
                      parent.location.reload();
                    });
                  }
                //服务器端返回处理逻辑
              },
              error:function(XmlHttpRequest,textStatus,errorThrown){
                layer.msg('操作失败:服务器处理失败');
            }
          }; 
          layui.use('form', function(){
            var form = layui.form;
            $('#mainForm').ajaxForm(jqForm_options).submit(function(data){
              //无逻辑
              console.log(data);
            }); 
          });
        })   

  </script>

{/block}